local huaiyuan = fk.CreateSkill{
    name = "ld__huaiyuan",
}

Fk:loadTranslationTable{
    ["ld__huaiyuan"] = "怀远",
    [":ld__huaiyuan"] = "与你势力相同角色的准备阶段，你可以令其以下项于本回合数值+1：1.攻击范围；2.手牌上限；3.使用【杀】的次数上限。",

    ["ld__huaiyuan_atkrange-turn"] = "攻击范围+1",
    ["ld__huaiyuan_maxcard-turn"] = "手牌上限+1",
    ["ld__huaiyuan_slash-turn"] = "使用【杀】的次数上限+1",
    ["@ld__huaiyuan_atkrange-turn"] = "攻击范围",
    ["@ld__huaiyuan_maxcard-turn"] = "手牌上限",
    ["@ld__huaiyuan_slash-turn"] = "杀的次数",
    ["#ld__huaiyuan_choose"] = "怀远：选择一项，令 %src 对应项于本回合数值+1 ",

    ["$ld__huaiyuan1"] = "当怀远志，砥砺奋进。",
    ["$ld__huaiyuan2"] = "举有成资，谋有全策。",
}

local H = require "packages.ol_hegemony.util"

huaiyuan:addEffect(fk.EventPhaseStart,{
    can_trigger  = function (self, event, target, player, data)
       return player:hasSkill(huaiyuan.name) and target.phase == Player.Start and H.compareKingdomWith(target, player)
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local choices = {"ld__huaiyuan_atkrange-turn", "ld__huaiyuan_maxcard-turn", "ld__huaiyuan_slash-turn"}
        if target.dead or player.dead then return end
        local choice = room:askToChoice(player,{
            choices = choices,
            skill_name = huaiyuan.name,
            prompt = "#ld__huaiyuan_choose:"..target.id,
            cancelable = false,
        })
        room:setPlayerMark(target, "@"..choice, 1)
    end,
})

huaiyuan:addEffect("maxcards",{
    correct_func = function(self, player)
        if player:getMark("@ld__huaiyuan_maxcard-turn") > 0 then
        return 1
      end
    end,
})

huaiyuan:addEffect("atkrange",{
    correct_func = function(self, from, to)
        if from:getMark("@ld__huaiyuan_atkrange-turn") > 0 then
        return 1
      end
    end,
})

huaiyuan:addEffect("targetmod", {
    residue_func = function(self, player, skill, scope)
    if skill.trueName == "slash_skill" and scope == Player.HistoryPhase and player:getMark("@ld__huaiyuan_slash-turn") > 0 then
        return 1
      end
    end,
})

return huaiyuan